package com.gitee.itembucket.core.theme

import com.gitee.itembucket.ItemBucket
import com.gitee.itembucket.core.bucket.Size
import org.bukkit.entity.Player
import taboolib.module.configuration.Config
import taboolib.module.configuration.Configuration

abstract class ThemeUI(val viewer: Player, val player: Player) {

    abstract fun open()


    class LayoutBuilder(val column: Int, val amount: Int) {

        constructor(size: Size) : this(ItemBucket.column, size.amount)

        fun <T> map(block: (Int, Int, Int) -> T) : List<T> {
            val listOf = mutableListOf<T>()
            (0 until amount).forEach { index ->
                // 行数 = 索引 / 列数
                val row = index / column
                // 列数 = 索引 % 列数
                val rColumn = index % column
                listOf += block(index,row, rColumn)
            }
            return listOf
        }

        fun forEach(block: (Int,Int, Int) -> Unit) {
            (0 until amount).forEach { index ->
                // 行数 = 索引 / 列数
                val row = index / column
                // 列数 = 索引 % 列数
                val rColumn = index % column
                block(index,row, rColumn)
            }
        }

    }

}